/**
 * This file is a part of qloudgen-rul. 
 * You can redistribute qloudgen-rul and/or modify it under the terms of the Lesser GNU General Public License version 3. 
 * qloudgen-rul is distributed WITHOUT ANY WARRANTY. 
 *
 * See the Lesser GNU General Public License for more details at http://www.gnu.org/licenses/. 
 **/
package org.qloudgen.rul.drools;

import java.util.Map;

/**
 * <p>Title: Drools Global Message</p>
 * <p>Description: Wrappered current authenticated information.</p>
 * <p>Copyright: qloudgen/rul 2014</p>
 * @author <a href="mailto:hyq.dd.sun@gmail.com">glue.3M</a>
 */
public final class Message {
	/**
	 * Current user id.
	 */
	private String userId = null;
	/**
	 * Current user attributes.
	 */
	private Map<String,Object> userAttributes = null;
	/**
	 * Current user permitted.
	 */
	private boolean permitted = false;
	
	/**
	 * Default constructor.
	 */
	public Message() {
	}
	
	/**
	 * Sets current user id.
	 *
	 * @param userId
	 */
	public void setUserId(final String userId) {
		this.userId = userId;
	}
	
	/**
	 * Returns current user id.
	 *
	 * @return userId
	 */
	public String getUserId() {
		return userId;
	}
	
	/**
	 * Sets current user attributes.
	 *
	 * @param userAttributes
	 */
	public void setUserAttributes(final Map<String,Object> userAttributes) {
		this.userAttributes = userAttributes;
	}
	
	/**
	 * Returns current user attributes.
	 *
	 * @return userAttributes
	 */
	public Map<String,Object> getUserAttributes() {
		return userAttributes;
	}
	
	/**
	 * Sets current user permitted.
	 *
	 * @param permitted
	 */
	public void setPermitted(final boolean permitted) {
		this.permitted = permitted;
	}
	
	/**
	 * Returns current user permitted.
	 *
	 * @return boolean
	 */
	public boolean isPermitted() {
		return permitted;
	}
	
	/**
	 * Returns the String representation.
	 *
	 * @return String
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append( "[" );
		builder.append( super.toString() );
		builder.append( "-->" );
		builder.append( "userId=" ).append( userId ).append( "," );
		builder.append( "userAttributes=" ).append( userAttributes ).append( "," );
		builder.append( "permitted=" ).append( permitted );
		builder.append( "]" );
		//
		return builder.toString();
	}
}